package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import java.util.Date;
import java.util.GregorianCalendar;

public class WEEK extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    Date localDate = TODATE.arguments2Date(paramArrayOfObject);
    GregorianCalendar localGregorianCalendar = new GregorianCalendar();
    localGregorianCalendar.setTime(localDate);
    return new Integer(localGregorianCalendar.get(3));
  }

  public Function.Type getType()
  {
    return Function.DATETIME;
  }

  public String getCN()
  {
    return "WEEK(serial_num):返回一个代表一年中的第几周的数字。\nSerial_num:表示输入的日期。\n备注:\nFineReport将日期保存为系列数，一个系列数代表一个与之匹配的日期，以方便用户对日期进行数值式计算。\n在1900年日期系统中，FineReport电子表格将1900年1月1日保存为系列数2，将1900年1月2日保存为系列数3，\n将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统，1998年1月1日存为系列数35796。\n示例:\nWEEK(\"2005/1/1\")等于1。\nWEEK(\"2005/1/6\")等于2。\nWEEK(35796)等于1。";
  }

  public String getEN()
  {
    return "WEEK(serial_num): Returns the number of week, represented by serial_num, in the year. \nSerial_num is the sequence number of the week you are trying to find.\n\nRemarks:\nFineReport stores dates as sequential serial numbers so they can be used in calculations.\nFineReport stores January 1, 1900 as serial number 2，January 2, 1900 as 3，\nJanuary 3, 1900 as 4, and so on, so January 1, 1998 as serial number 35796.\n\nExample:\n   WEEK(\"2005/1/1\") = 1\n   WEEK(\"2005/1/6\") = 2\n   WEEK(35796) = 1";
  }
}